<?php
namespace BoxEdu\Hooks;
class SubjectOrderTopicHooks extends \HooksController
{

    function topic_before_save_orderComment(&$params){
					  if(trim(strip_tags($params['content']))=="" && trim(strip_tags($params['title']))==""){
									  exit(json_encode(array('error'=>3,'msg'=>'提交内容不能为空')));
							} 
							$allow_tags=str_replace("<img>","",dict("allow_tags"));
							$params['content']=strip_tags($params['content'],$allow_tags);
							$params['title']=strip_tags($params['title'],$allow_tags);
							//dump($params);
						 if(!$params['id']){
								$data = BoxModel("sns_topic")->where(array('user_id'=>$this->user_id,'pid'=>$params['pid']))->find();
        if($data){
								  exit(json_encode( array('error'=>1,'msg'=>'您已经发布过学员心声了')));	
								}
							}
					}
					
					
				 function topic_insert_orderComment(&$params){
								$user_info = BoxModel("system_member")->where(array('user_id'=>$this->user_id))->find();
								$title=$params['title']?$params['title']:$params['content'];
								 /*********提问数减少*******/
        $row = array(
            'user_id' => $this->user_id,
            'title' => cutstr(htmlspecialchars($title), "50"),
												'url'=>HomeUrl.U('Index/subject_detail',array('subject_id'=>$params['pid'])),
												'event'=>'00020',
            'subjectid' => intval($params['pid']),
        );
							//	dump($row);exit();
        $r = Logic('BoxSns', 'Log')->add($row);
						}
							
						
}
